<template>
	<div class="iInfo" element-loading-text="加载中" v-loading="loading">
		<div class="flex">
			<div class="lumpBox">
				<el-page-header :content="head" @back="$router.go(-1)"></el-page-header>
				<div class="Lbox-content">
					<div class="ibox">
						<div class="flex" style="margin-top: 15px;flex: 1;">
							<div class="lumpBox" style="flex: 2;">
								<div class="Lbox-title">
									<h2 style="margin: 15px 0;">项目信息</h2>
									<div class="operation">
										<el-button type="primary" size="small">立项</el-button>
										<el-button type="danger" size="small">驳回</el-button>
										<el-button type="primary" size="small">结项</el-button>
										<el-button type="danger" size="small">驳回</el-button>
										<el-button type="primary" @click="elForm.edit=true" size="small">编辑</el-button>
									</div>
								</div>
								<div class="Lbox-content">
									<projectDetails @cancel="EditCancel" :elForm="elForm" ref="projectDetails"></projectDetails>
								</div>
							</div>
						</div>
						<div class="flex" style="margin-top: 15px;flex: 0 0 auto;">
							<div class="lumpBox">
								<div class="Lbox-title"><h2>附件</h2></div>
								<div class="Lbox-content">
									<el-table :data="tableData" border class="table" style="width: 100%" key="tableData">
										<el-table-column prop="file_name" label="附件名称">
										</el-table-column>
										<el-table-column prop="file_code" label="附件编号">
										</el-table-column>
										<el-table-column prop="attach_type" label="附件类型">
										</el-table-column>
										<el-table-column prop="create_time" :formatter="timeFormatter" label="上传时间">
										</el-table-column>
										<el-table-column prop="file_path" label="操作">
											<template slot-scope="scope">
													<el-button type="primary" icon="el-icon-download" size="mini"	@click="delStaff(scope.row.file_path)">下载</el-button>
											</template>
										</el-table-column>
									</el-table>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
import projectDetails from './popup/project_details.vue'
export default {
	name: 'manage_details',
	data() {
		return {
			head: decodeURI(this.$route.query.head),
			tableData: [],
			elForm: {
				type: 1,
				edit: false,
				project_class: 1,
				project_type: 2,
				customer: '',
				project_name: '',
				date1: '',
				date2: '',
				date3: '',
				user: '',
				performance: '',
				remark: '',
				direction: '',
				file: []
			},
			loading: false
		};
	},
	computed: {
    projectId () {
      return this.$route.query.projectId
    },
  },
	components: { projectDetails },
	created() {
		this.$emit('pass', '/manage');
	},
	mounted() {},
	methods: {
		timeFormatter(row, col, input) {
			var date = new Date(input);
			var yy = date.getFullYear();
			if (yy < 1900) yy = yy + 1900;
			var MM = date.getMonth() + 1;
			if (MM < 10) MM = "0" + MM;
			var dd = date.getDate();
			if (dd < 10) dd = "0" + dd;
			var hh = date.getHours();
			if (hh < 10) hh = "0" + hh;
			var mm = date.getMinutes();
			if (mm < 10) mm = "0" + mm;
			var ss = date.getSeconds();
			if (ss < 10) ss = "0" + ss;
			return yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss;
		},
		delStaff(flag) {
			this.$layer.confirm('确定下载?', {
				icon: 1
			}, function () {
				this.$layerlayer.closeAll();
				window.open(flag);
			})
		},
		EditCancel() {
			this.elForm.edit = false
		}
	}
};
</script>
